<?
if (!defined('SMF'))
	die('Hacking attempt...');
	
global $smcFunc, $txt, $scripturl, $settings, $user_info;
global $dbtables, $color_header, $color_line1, $color_line2;

// Verify user login, if CheckLogin() returns false return to the calling script/function
if (CheckLogin() == false)
	return;

bigtitle($txt['bnt_report_title']);

//-------------------------------------------------------------------------------------------------

// Pull player info into $playerinfo.
$result = $smcFunc['db_query']('', '
	SELECT *
	FROM {raw:db_ships}
	WHERE user_id = {int:user_id}
	LIMIT 1',
	array(
		'db_ships' => $dbtables['ships'],
		'user_id' => $user_info['id'],
	)
);
$playerinfo = $smcFunc['db_fetch_assoc']($result);
$smcFunc['db_free_result']($result);

$shiptypes[0] = "tinyship.gif";
$shiptypes[1] = "smallship.gif";
$shiptypes[2] = "mediumship.gif";
$shiptypes[3] = "largeship.gif";
$shiptypes[4] = "hugeship.gif";

$shipavg = $playerinfo['hull'] + $playerinfo['engines'] + $playerinfo['power'] + $playerinfo['computer'] + $playerinfo['sensors'] + $playerinfo['armor'] + $playerinfo['shields'] + $playerinfo['beams'] + $playerinfo['torp_launchers'] + $playerinfo['cloak'];
$shipavg /= 10;

if($shipavg < 8)
	$shiplevel = 0;
elseif($shipavg < 12)
	$shiplevel = 1;
elseif($shipavg < 16)
	$shiplevel = 2;
elseif($shipavg < 20)
	$shiplevel = 3;
else
	$shiplevel = 4;

echo '
		<table class="ship_report_table" border="0" cellspacing="3" cellpadding="0" width="100%">
			<tr bgcolor="', $color_header, '">
				<td><b>', $txt['bnt_player'], ': ', $playerinfo['character_name'], '</b></td>
				<td align="center"><b>', $txt['bnt_ship'], ': ', $playerinfo['ship_name'], '</b></td>
				<td align="right"><b>', $txt['bnt_credits'], ': ', NUMBER($playerinfo['credits']), '</b></td>
			</tr>
		</table>
		<br>
		<table border="0" cellspacing="0" cellpadding="2" width="100%">
			<tr>
				<td>
					<table class="ship_report_table" border="0" cellspacing="0" cellpadding="0" width="100%">
						<tr bgcolor="', $color_header, '">
							<td><b>', $txt['bnt_ship_levels'], '</b></td>
							<td></td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_hull'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['hull'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_engines'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['engines'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_power'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['power'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_computer'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['computer'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_sensors'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['sensors'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_armor'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['armor'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_shields'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['shields'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_beams'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['beams'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_torp_launch'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['torp_launchers'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_cloak'], '</td>
							<td>', $txt['bnt_level'], ' ', $playerinfo['cloak'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td><i>', $txt['bnt_shipavg'], '</i></td>
							<td>', $txt['bnt_level'], ' ', NUMBER($shipavg, 2), '</td>
						</tr>
					</table>
				</td>
				<td valign="top">
					<table class="ship_report_table" border="0" cellspacing="0" cellpadding="0" width="100%">';

$holds_used = $playerinfo['ship_ore'] + $playerinfo['ship_organics'] + $playerinfo['ship_goods'] + $playerinfo['ship_colonists'];
$holds_max = NUM_HOLDS($playerinfo['hull']);

echo '
						<tr bgcolor="', $color_header, '">
							<td><b>', $txt['bnt_holds'], '</b></td>
							<td align="right"><b>', NUMBER($holds_used),' / ', NUMBER($holds_max), '</b></td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_ore'], '</td>
							<td align="right">', NUMBER($playerinfo['ship_ore']), '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_organics'], '</td>
							<td align="right">', NUMBER($playerinfo['ship_organics']), '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_goods'], '</td>
							<td align="right">', NUMBER($playerinfo['ship_goods']), '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_colonists'], '</td>
							<td align="right">', NUMBER($playerinfo['ship_colonists']), '</td>
						</tr>
						<tr>
							<td>&nbsp;</td>
						</tr>';

$armor_pts_max = NUM_ARMOUR($playerinfo['armor']);
$ship_fighters_max = NUM_FIGHTERS($playerinfo['computer']);
$torps_max = NUM_TORPEDOES($playerinfo['torp_launchers']);

echo '
						<tr bgcolor="', $color_header, '">
							<td><b>', $txt['bnt_arm_weap'], '</b></td>
							<td></td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_armorpts'], '</td>
							<td align="right">', NUMBER($playerinfo['armor_pts']), ' / ', NUMBER($armor_pts_max), '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_fighters'], '</td>
							<td align=right>', NUMBER($playerinfo['ship_fighters']), ' / ',  NUMBER($ship_fighters_max), '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_torps'], '</td>
							<td align="right">', NUMBER($playerinfo['torps']), ' / ', NUMBER($torps_max), '</td>
						</tr>
				</table>
			</td>
				<td valign="top">
					<table class="ship_report_table" border="0" cellspacing="0" cellpadding="0" width="100%">';

$energy_max = NUM_ENERGY($playerinfo['power']);

echo '
						<tr bgcolor="', $color_header, '">
							<td><b>', $txt['bnt_energy'], '</b></td>
							<td align="right"><b>', NUMBER($playerinfo['ship_energy']), ' / ', NUMBER($energy_max), '</b></td>
						</tr>
						<tr>
							<td>&nbsp;</td>
						</tr>
						<tr bgcolor="', $color_header, '">
							<td><b>', $txt['bnt_devices'], '</b></td>
							<td></td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_beacons'], '</td>
							<td align="right">', $playerinfo['dev_beacon'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_warpedit'], '</td>
							<td align="right">', $playerinfo['dev_warpedit'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_genesis'], '</td>
							<td align="right">', $playerinfo['dev_genesis'], '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_deflect'], '</td>
							<td align="right">', $playerinfo['dev_minedeflector'], '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_ewd'], '</td>
							<td align="right">', $playerinfo['dev_emerwarp'], '</td>
						</tr>';

$escape_pod = ($playerinfo['dev_escapepod'] == 'Y') ? $txt['bnt_yes'] : $txt['bnt_no'];
$fuel_scoop = ($playerinfo['dev_fuelscoop'] == 'Y') ? $txt['bnt_yes'] : $txt['bnt_no'];
$lssd = ($playerinfo['dev_lssd'] == 'Y') ? $txt['bnt_yes'] : $txt['bnt_no'];

echo '
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_escape_pod'], '</td>
							<td align="right">', $escape_pod, '</td>
						</tr>
						<tr bgcolor="', $color_line1, '">
							<td>', $txt['bnt_fuel_scoop'], '</td>
							<td align="right">', $fuel_scoop, '</td>
						</tr>
						<tr bgcolor="', $color_line2, '">
							<td>', $txt['bnt_lssd'], '</td>
							<td align="right">', $lssd, '</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
		<p align=center><img src="', $settings['images_url'], '/bnt/', $shiptypes[$shiplevel], '" border="0"></p>';

TextMainMenu();
?>

